package xuexi;


enum ColorTwo{      //定义枚举类
    RED("红色"),GREEN("绿色"),BULE("蓝色");//枚举对象，只能定义在枚举类的首行
    private String title;

    private ColorTwo(String title) {
        this.title = title;
    }

    @Override
    public String toString() {
        return "ColorTwo{" +
                "title='" + title + '\'' +
                '}';
    }
}
public class enumClass {
    public static void main(String[] args){
//        ColorTwo c=ColorTwo.RED;
//        switch (c){           //枚举类可与switch一起使用
//            case RED:
//                System.out.println(ColorTwo.RED);
//                break;
//            case GREEN:
//                System.out.println(ColorTwo.GREEN);
//                break;
//            case BULE:
//                System.out.println(ColorTwo.BULE);
//                break;
//        }
        for (ColorTwo c:ColorTwo.values()) {
//            System.out.println(c);
            System.out.println(c.ordinal()+"--"+c.name()+"--"+c.toString());  //Enum的两个方法
        }
    }
}
